#include <iostream>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string>
using namespace std;

#define _DEBUG_

int get_next_key ()
{
	return rand() % 256;
}

int main (int argc, char* argv[])
{
	int srand_seed;
	string str = argv[1];
	string des_file_name = str + ".cry";

	printf ("Key: ");
	scanf ("%d", &srand_seed);
	srand(srand_seed);
	
	FILE *fp_cry_src = fopen(argv[1], "rb+");
	FILE *fp_cry_des = fopen(&des_file_name[0], "wb");

	int tmp;
	while ((tmp = fgetc(fp_cry_src)) != EOF)
	{
		tmp ^= get_next_key();

		fputc(tmp,fp_cry_des);
	}

	return 0;
}

